Listing 5 shows the CreateSampleAtomListTweenData routine, which creates the atom list data used in Listing 7 and Listing 19 .
Listing 5 Utility routine CreateSampleAtomListTweenData
QTAtomContainer CreateSampleAtomListTweenData( long whichOne )
{
OSErr err = noErr;
QTAtomContainer atomListContainer;
QTAtomType tweenAtomType;
UInt32 elementDataType;
UInt16 resourceID;
err = QTNewAtomContainer( &atomListContainer );
if ( err ) goto bail;
// kListElementDataType atom specifies the data type of the elements
elementDataType = kTweenTypeShort;
err = QTInsertChild( atomListContainer, kParentAtomIsContainer,
kListElementDataType, 1, 1,
sizeof(tweenAtomType),
&tweenAtomType, nil );
// kListElementType atom tells which type of atoms to look for
tweenAtomType = 'pcid';
err = QTInsertChild( atomListContainer, kParentAtomIsContainer,
kListElementType, 1, 1, sizeof(tweenAtomType),
&tweenAtomType, nil );
switch ( whichOne ) {
case 1:
resourceID = 1000;
err = QTInsertChild( atomListContainer,
kParentAtomIsContainer, 'pcid', 1, 1,
sizeof(resourceID), &resourceID, nil );
if ( err ) goto bail;
resourceID = 1001;
err = QTInsertChild( atomListContainer,
kParentAtomIsContainer, 'pcid', 2, 2,
sizeof(resourceID), &resourceID, nil );
if ( err ) goto bail;
resourceID = 1002;
err = QTInsertChild( atomListContainer,
kParentAtomIsContainer, 'pcid', 3, 3,
sizeof(resourceID), &resourceID, nil );
if ( err ) goto bail;
break;
case 2:
resourceID = 1003;
err = QTInsertChild( atomListContainer,
kParentAtomIsContainer, 'pcid', 1, 1,
sizeof(resourceID), &resourceID, nil );
if ( err ) goto bail;
resourceID = 1004;
err = QTInsertChild( atomListContainer,
kParentAtomIsContainer, 'pcid', 2, 2,
sizeof(resourceID), &resourceID, nil );
if ( err ) goto bail;
resourceID = 1005;
err = QTInsertChild( atomListContainer,
kParentAtomIsContainer, 'pcid', 3, 3,
sizeof(resourceID), &resourceID, nil );
if ( err ) goto bail;
break;
}
bail:
if ( err && atomListContainer )
{ QTDisposeAtomContainer( atomListContainer );
atomListContainer = nil; }
return atomListContainer;
}
| Previous | Chapter Contents | Chapter Top | Next |